package git12;

public class Lock {
    public  String Lock(String key) {

//将字符串转为字符数组进行加法运算
        String key1 = key;
        char[] arr = key1.toCharArray();
        char arr1[]=new char[arr.length];
        for (int i = 0; i <arr.length; i++) {
            arr1[i]= (char) (arr[i]+(i+1)+3);
        }
//实现字符首尾位置交换
        char temp=arr1[0];
        arr1[0]=arr1[arr1.length-1];
        arr1[arr1.length-1]=temp;
//将字符数组转为字符串并反转
        String key2=new String(arr1);
        StringBuilder sb=new StringBuilder(key2).reverse();
        return sb.toString();
	//添加注释
    }
}
